<template>
    <el-button plain @click="dialogVisible = true">
        创建入库订单
    </el-button>

    <el-dialog
        v-model="dialogVisible"
        title="创建入库"
        width="800"
    >
        <el-form :model="form" label-width="auto" style="max-width: 600px">
            <el-form-item label="Name">
                <el-input v-model="form.name" />
            </el-form-item>
            <el-form-item label="Kind">
                <el-input v-model="form.kind" />
            </el-form-item>
            <el-form-item label="unit">
                <el-input v-model="form.unit" />
            </el-form-item>
            <el-form-item label="Number">
                <el-input v-model="form.number" />
            </el-form-item>
            <el-form-item label="Warehouse">
                <el-input v-model="form.warehouse" />
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">Create</el-button>
                <el-button @click="dialogVisible = false">Cancel</el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
</template>

<script  setup>
import { ref } from 'vue'
import {createInbound} from '@/api/create'
const dialogVisible = ref(false)
import { reactive } from 'vue'

// do not use same name with ref
const form = ref({
    name: '',
    kind: '',
    unit: ref(null),
    number: ref(null),
    warehouse: '',
})

const onSubmit = () => {
    console.log('submit!');
    console.log(form.value);
    const result = createInbound(form.value);
    console.log(result)
    dialogVisible.value = false
}
</script>
